<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Register</title>
<script type="text/javascript">

function validateForm(form){
	
	var varusername = form.username.value;
	var varpassword = form.password.value;
	var varaddress = form.address.value;
	var varzipcode = form.zipcode.value;
	var varcity = form.city.value;
	var varemail = form.email.value;
	var varfirstname = form.firstname.value;
	var varsurname = form.surname.value;
	
	
	if(varusername == null || varusername == "" || varusername.length < 3 || varusername.length > 16){
		alert("username need to be between 3 and 16 characters");
		form.username_text.focus();
		return false;
	}
	if(varpassword == null || varpassword == "" || varpassword.length < 3 || varpassword.length > 16){
		alert("password need to be between 3 and 16 characters");
		form.password_text.focus();
		return false;
	}
	if(varaddress == null || varaddress == ""){
		alert("address need a value");
		form.address_text.focus();
		return false;
	}
	if(varzipcode == null || varzipcode == ""){
		alert("zipcode need a value");
		form.zipcode_text.focus();
		return false;
	}
	if(varcity == null || varcity == ""){
		alert("city need a value");
		form.city_text.focus();
		return false;
	}
	if(varemail == null || varemail == "" || varemail.indexOf('@') < 1){
		alert("you need a valid");
		form.email_text.focus();
		return false;
	}
	if(varfirstname == null || varfirstname == ""){
		alert("firstname need a value");
		form.firstname_text.focus();
		return false;
	}
	if(varsurname == null || varsurname == ""){
		alert("surname need a value");
		form.surname_text.focus();
		return false;
	}
		return true;	
}
</script>
</head>
<body>
<div id="container">
<jsp:include page="../header.jsp" />
<jsp:include page="../menu.jsp" />
<div id="content">
	<form name="registerForm" action="login" method="post" onsubmit="return validateForm(this);">
		<table>
			<tr>
				<td>username</td><td><input type="text" name="username" value=""/></td>
			</tr>
			<tr>
				<td>password</td><td><input type="password" name="password" value=""/></td>
			</tr>
			<tr>
				<td>address</td><td><input type="text" name="address" value=""/></td>
			</tr>
			<tr>
				<td>zipcode</td><td><input type="text" name="zipcode" value=""/></td>
			</tr>
			<tr>
				<td>city</td><td><input type="text" name="city" value=""/></td>
			</tr>
			<tr>
				<td>email</td><td><input type="text" name="email" value=""/></td>
			</tr>
			<tr>
				<td>firstname</td><td><input type="text" name="firstname" value=""/></td>
			</tr>
			<tr>
				<td>surname</td><td><input type="text" name="surname" value=""/></td>
			</tr>
			<tr>
				<td><input type="submit" value="Register"/></td>
			</tr>
		</table>
		<input type="hidden" name="hidden" value="0" />
	</form>
</div>
<jsp:include page="../footer.jsp" />
</div>
</body>
</html>